import { omit } from 'lodash'
import { ApiProperty } from '@midwayjs/swagger'
import { Rule, RuleType } from '@midwayjs/validate'
import { BaseEntity } from './base.entity'
import { objectToKebabCase } from '../utils'


export class BaseDTO<T extends BaseEntity> {
  @ApiProperty()
  @Rule(RuleType.allow(null))
  id: string
  toEntity() {
    return omit(objectToKebabCase(this), ['create_date', 'update_date'] as any)
  }
}